package com.example.springboot.mapper;

import com.example.springboot.bean.Employee;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @Author:ChenZhangKun
 * @Date: 2020/10/9 21:25
 */
public interface EmployeeMapper {
    /**
     * 通过id获得
     *
     * @param id
     * @return
     */
    Employee getById(Integer id);

    /**
     * 插入
     *
     * @param employee
     */
    void insertEmp(Employee employee);

    /**
     * 更新
     *
     * @param employee
     */
    @Update("UPDATE employee SET lastName=#{lastName},email=#{email},gender=#{gender},d_id=#{dId} WHERE id = #{id}")
    void updateEmp(Employee employee);

    /**
     * 删除
     *
     * @param id
     */
    @Delete("DELETE FROM employee WHERE id = #{id}")
    void delete(Integer id);

    /**
     *
     * @param name
     * @return
     */
    @Select("SELECT * FROM employee WHERE lastName=#{name}")
    Employee selectByLastName(String name);

    List<Employee> selectByParam(@Param("employee") Employee employee);
}
